//
//  WBNavigationController.m
//  微博项目
//
//  Created by ma c on 16/8/14.
//  Copyright (c) 2016年 beijing. All rights reserved.
//

#import "WBNavigationController.h"
#import "UIBarButtonItem+WBExtension.h"

@interface WBNavigationController ()

@end

@implementation WBNavigationController

+ (void)initialize{
    //设置整个全局的item
    UIBarButtonItem * item = [UIBarButtonItem appearance];
    //设置普通状态
    [item setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSForegroundColorAttributeName:[UIColor orangeColor]} forState:UIControlStateNormal];
    //设置不可用状态
    [item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:0.6]} forState:UIControlStateDisabled];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    //判断push进来的控制器不是第一个子控制器，
    if (self.viewControllers.count > 0) {
        //隐藏底部tabBar
        viewController.hidesBottomBarWhenPushed = YES;
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) image:@"navigationbar_back" hightImage:@"navigationbar_back_highlighted"];
        
        viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(more) image:@"navigationbar_more" hightImage:@"navigationbar_more_hghted"];
    }
    [super pushViewController:viewController animated:YES];
    
    
}
- (void)back{
    [self popViewControllerAnimated:YES];
}

- (void)more{
    [self popToRootViewControllerAnimated:YES];
}

@end
